/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ga.coordination;

import java.util.ArrayList;

/**
 *
 * @author hartono
 */
public class Truck {
    public int capacity;
    public ArrayList<OneWayTrip> path;
    
    public Truck() {
        path = new ArrayList<OneWayTrip>();
    }

    public Truck(int capacity) {
        this.capacity = capacity;
        path = new ArrayList<OneWayTrip>();
    }
        

    @Override
    public String toString() {
        return "Truck, Capacity:"+capacity;
    }
    
    public void generatePath(ArrayList<Byte> compactIndividu, StringBuffer pathTruck, byte [][][] pathList){
        
        int i =0;        
        int idx=0;
        for(i=1; i< pathTruck.length();i++){
            OneWayTrip one = new OneWayTrip();
            one.source = pathTruck.charAt(i-1);
            one.destination = pathTruck.charAt(i);
            if (one.source == 'P'){
                one.idMachineList.clear();            
                
            }else {
                OneWayTrip before = path.get(path.size()-1);
                one.idMachineList.addAll(before.idMachineList);
                if (idx < compactIndividu.size()){
                    one.idMachineList.add(compactIndividu.get(idx));
                    idx++;
                }
            }
            path.add(one);
            
        }
    }
    
    public void PrintPath(){
        for (OneWayTrip o : path){
            System.out.println(o.source + " - "+o.destination + ":" + o.idMachineList);
        }
    }    
    
}
